// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#pragma once

#include <melon/executor.h>
#include <melon/executors/cpu_thread_pool_executor.h>

#include <pollux/common/base/runtime_metrics.h>
#include <pollux/vector/flat_vector.h>
#include <pollux/vector/vector_maker.h>

#include <gtest/gtest.h>
#include <optional>
#include <pollux/type/cpp_to_type.h>
#include <pollux/vector/vector_fuzzer.h>
#include <pollux/vector/vector_builder.h>

namespace kumo::pollux::test {

    // TODO: enable ASSERT_EQ for vectors.
    void assertEqualVectors(const VectorPtr &expected, const VectorPtr &actual);

    // Verify that the values in both 'expected' and 'actual' vectors is the same
    // but only for the rows marked valid in 'rowsToCompare'.
    void assertEqualVectors(
        const VectorPtr &expected,
        const VectorPtr &actual,
        const SelectivityVector &rowsToCompare);

    /// Verify that 'vector' is copyable, by copying all rows.
    void assertCopyableVector(const VectorPtr &vector);

    class TestRuntimeStatWriter : public BaseRuntimeStatWriter {
    public:
        void addRuntimeStat(const std::string &name, const RuntimeCounter &value)
        override {
            stats_.emplace_back(name, value);
        }

        const std::vector<std::pair<std::string, RuntimeCounter> > &stats() const {
            return stats_;
        }

    private:
        std::vector<std::pair<std::string, RuntimeCounter> > stats_;
    };
} // namespace kumo::pollux::test
